package pers.lc.testDataGenerator.rule;

import java.util.List;
import java.util.Random;

/**
 * 集合选取规则
 */
public class ColumnSetRule {
    private String type;
    private String interval;
    public ColumnSetRule(){

    }
    public ColumnSetRule(String type,String interval){
        this.type = type;
        this.interval = interval;
    }

    public String getType() {
        return type;
    }

    public String getInterval() {
        return interval;
    }

    public void setInterval(String interval) {
        this.interval = interval;
    }

    public void setType(String type) {
        this.type = type;
    }
    public static String singleRule1(List<String> list){
        Random random = new Random();
        return list.get(random.nextInt(list.size()));
    }
    public static String multiRule1(List<String> list){
        return singleRule1(list);
    }
    public static String multiRule2(List<String> list,String interval,int count){
        int intervalInt = Integer.valueOf(interval);
        int index = count*intervalInt;
        return list.get(index>list.size()-1?Math.floorMod(index,list.size()-1):index);
    }
}
